home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / ixemul / sdk / man / cat2 / semctl.0 < prev    next >
Encoding:
Text File  |  1998-06-15  |  5.6 KB  |  121 lines

  1.  
  2. SEMCTL(2)                  UNIX Programmer's Manual                  SEMCTL(2)
  3.  
  4. NNAAMMEE
  5.      sseemmccttll - semaphore control operations
  6.  
  7. SSYYNNOOPPSSIISS
  8.      ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
  9.      ##iinncclluuddee <<ssyyss//iippcc..hh>>
  10.      ##iinncclluuddee <<ssyyss//sseemm..hh>>
  11.  
  12.      _i_n_t
  13.      sseemmccttll(_i_n_t _s_e_m_i_d, _i_n_t _s_e_m_n_u_m, _i_n_t _c_m_d, _u_n_i_o_n _s_e_m_u_n _a_r_g)
  14.  
  15. DDEESSCCRRIIPPTTIIOONN
  16.      The sseemmccttll() system call provides a number of control operations on the
  17.      semaphore specified by _s_e_m_n_u_m and _s_e_m_i_d. The operation to be performed is
  18.      specified in _c_m_d (see below).  _a_r_g is a union of the following fields:
  19.  
  20.          int     val;            /* value for SETVAL */
  21.          struct  semid_ds *buf;  /* buffer for IPC_{STAT,SET} */
  22.          u_short *array;         /* array for GETALL & SETALL */
  23.  
  24.      The semid_ds  structure used in the IPC_SET and IPC_STAT commands is de-
  25.      fined as follows in <_s_y_s_/_s_e_m_._h>:
  26.  
  27.      struct semid_ds {
  28.          struct ipc_perm sem_perm;  /* operation permissions */
  29.          struct  sem *sem_base;     /* semaphore set */
  30.          u_short sem_nsems;         /* number of sems in set */
  31.          time_t  sem_otime;         /* last operation time */
  32.          time_t  sem_ctime;         /* last change time */
  33.      };
  34.  
  35.      The ipc_perm  structure used inside the semid_ds  structure is defined in
  36.      <_s_y_s_/_i_p_c_._h> and looks like this:
  37.  
  38.      struct ipc_perm {
  39.          ushort cuid; /* creator user id */
  40.          ushort cgid; /* creator group id */
  41.          ushort uid;  /* user id */
  42.          ushort gid;  /* group id */
  43.          ushort mode; /* r/w permission (see chmod(2)) */
  44.          ushort seq;  /* sequence # (to generate unique msg/sem/shm id) */
  45.          key_t key;   /* user specified msg/sem/shm key */
  46.      };
  47.  
  48.      sseemmccttll() provides the following operations:
  49.  
  50.      GETVAL     Return the value of the semaphore.
  51.  
  52.      SETVAL     Set the value of the semaphore to _a_r_g_._v_a_l.
  53.  
  54.      GETPID     Return the pid of the last process that did an operation on
  55.                 this semaphore.
  56.  
  57.      GETNCNT    Return the number of processes waiting to acquire the
  58.                 semaphore.
  59.  
  60.      GETZCNT    Return the number of processes waiting for the value of the
  61.                 semaphore to reach 0.
  62.  
  63.      GETALL     Return the values for all the semaphores associated with
  64.  
  65.  
  66.                 _s_e_m_i_d.
  67.  
  68.      SETALL     Set the values for all the semaphores that are associated with
  69.                 the semaphore identifier _s_e_m_i_d to the corresponding values in
  70.                 _a_r_g_._a_r_r_a_y.
  71.  
  72.      IPC_STAT   Gather statistics about a semaphore and place the information
  73.                 in the semid_ds  structure pointed to by _a_r_g_._b_u_f (see above).
  74.  
  75.      IPC_SET    Set the value of the _s_e_m___p_e_r_m_._u_i_d, _s_e_m___p_e_r_m_._g_i_d and
  76.                 _s_e_m___p_e_r_m_._m_o_d_e fields in the structure associated with the
  77.                 semaphore.  The values are taken from the corresponding fields
  78.                 in the structure pointed to by _a_r_g_._b_u_f. This operation can on-
  79.                 ly be executed by the super-user, or a process that has an ef-
  80.                 fective user id equal to either _s_e_m___p_e_r_m_._c_u_i_d or _s_e_m___p_e_r_m_._u_i_d
  81.                 in the data structure associated with the message queue.
  82.  
  83.      IPC_RMID   Remove the semaphores associated with _s_e_m_i_d from the system
  84.                 and destroy the data structures associated with it. Only the
  85.                 super-user or a process with an effective uid equal to the
  86.                 _s_e_m___p_e_r_m_._c_u_i_d or _s_e_m___p_e_r_m_._u_i_d values in the data structure as-
  87.                 sociated with the semaphore can do this.
  88.  
  89.      The permission to read or change a message queue (see semop(2))  is de-
  90.      termined by the _s_e_m___p_e_r_m_._m_o_d_e field in the same way as is done with files
  91.      (see chmod(2)),  but the effective uid can match either the _s_e_m___p_e_r_m_._c_u_i_d
  92.      field or the _s_e_m___p_e_r_m_._u_i_d field, and the effective gid can match either
  93.      _s_e_m___p_e_r_m_._c_g_i_d or _s_e_m___p_e_r_m_._g_i_d.
  94.  
  95. RREETTUURRNN VVAALLUUEESS
  96.      For the GETVAL, GETPID, GETNCNT and GETZCNT operations, sseemmccttll() returns
  97.      one of the values described above if successful. All other operations
  98.      will make sseemmccttll() return 0 if no errors occur. Otherwise -1 is returned
  99.      and _e_r_r_n_o set to reflect the error.
  100.  
  101. EERRRROORRSS
  102.      sseemmccttll() will fail if:
  103.  
  104.      [EPERM]       _c_m_d is equal to IPC_SET or IPC_RMID and the caller is not
  105.                    the super-user, nor does the effective uid match either the
  106.                    _s_e_m___p_e_r_m_._u_i_d or _s_e_m___p_e_r_m_._c_u_i_d fields of the data structure
  107.                    associated with the message queue.
  108.  
  109.      [EACCESS]     The caller has no operation permission for this semaphore.
  110.  
  111.      [EINVAL]      _s_e_m_i_d is not a valid message semaphore identifier.
  112.  
  113.                    _c_m_d is not a valid command.
  114.  
  115.      [EFAULT]      _a_r_g_._b_u_f specifies an invalid address.
  116.  
  117. SSEEEE AALLSSOO
  118.      semop(2) semget(2)
  119.  
  120.  NetBSD                         August 17, 1995                              2
  121.